﻿#region Copyright Info

// 
// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

#region

using System.Collections.Generic;
using System.Linq;
#if NUNIT
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using Majesty_of_Omega.Model.Research;
#elif MBUNIT
using MbUnit.Framework;
using TestClass = MbUnit.Framework.TestFixtureAttribute;
using TestMethod = MbUnit.Framework.TestAttribute;
using TestInitialize = MbUnit.Framework.SetUpAttribute;
using TestCleanup = MbUnit.Framework.TearDownAttribute;
using ClassInitialize = MbUnit.Framework.TestFixtureSetUpAttribute;
using ClassCleanup = MbUnit.Framework.TestFixtureTearDownAttribute;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif


#endregion

namespace Test.Majesty_of_Omega.BL.Model
{
    /// <summary>
    /// Tests for the <see cref="TechLevelInfo"/ class>
    /// </summary>
    [TestClass]
    public class TestTechLevelInfoClass
    {
        /// <summary>
        /// Tests the relativ physics at level 0. 
        /// All level 0 technologies are researched by default
        /// </summary>
        /// <remarks>
        /// At level 0 there, should be only the trusters technology
        /// </remarks>
        [Test]
        public void TestRelativPhysicsLevel0()
        {
            const int techLevelTest = 0;
            const string testTechField = "RelPh";
            const int expectedNumberOfTechs = 1;
            const ResearchState researchedExpected = ResearchState.Researched;

            AssertCorrectTechLevel(techLevelTest, testTechField, expectedNumberOfTechs, researchedExpected);
        }

        /// <summary>
        /// Tests the relativ physics at level 5. 
        /// All level 5 technologies are not researched by default
        /// </summary>
        /// <remarks>
        /// At level 5 there, should be only the improved trusters technology
        /// </remarks>
        [Test]
        public void TestRelativPhysicsLevel5()
        {
            const int techLevelTest = 5;
            const string testTechField = "RelPh";
            const int expectedNumberOfTechs = 0;
            const ResearchState researchedExpected = ResearchState.Unknown;

            AssertCorrectTechLevel(techLevelTest, testTechField, expectedNumberOfTechs, researchedExpected);
        }

        private static void AssertCorrectTechLevel(int techLevelTest, string testTechField, int expectedNumberOfTechs, ResearchState researchedExpected)
        {
            ResearchManager manager = new ResearchManager();
            TechLevelInfo techLevelInfo = new TechLevelInfo(techLevelTest, manager.GetTechFieldResearch(testTechField));
            IEnumerable<TechApplicationStateInfo> applicationStateInfos = techLevelInfo.TechApplicationStateInfos;
            Assert.AreEqual(expectedNumberOfTechs, applicationStateInfos.Count());
            if (expectedNumberOfTechs > 0 )
                Assert.AreEqual(researchedExpected, applicationStateInfos.First().ResearchState);
        }
    }
}
